# coding=utf-8
import threading

val = 0

gLock = threading.Lock()


def add():
    global val
    gLock.acquire()
    for i in range(1000000):
        val += 1
    gLock.release()
    print(val)


if __name__ == '__main__':
    for x in range(2):
        t = threading.Thread(target=add)
        t.start()
